package com.pet.controller.webUser;

import com.pet.dto.web.PetAdoptApplicationDTO;
import com.pet.result.Result;
import com.pet.service.PetAdoptApplicationService;
import com.pet.vo.web.PetAdoptApplicationVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
@Slf4j
public class PetAdoptApplicationController {

    @Autowired
    private PetAdoptApplicationService petAdoptApplicationService;

    /**
     * 添加宠物领养申请
     * @param petAdoptApplicationDTO
     * @return
     */
    @PostMapping("/petAdoptApplication")
    private Result insertPetAdoptApplication(@RequestBody PetAdoptApplicationDTO petAdoptApplicationDTO){
        petAdoptApplicationService.insertPetAdoptApplication(petAdoptApplicationDTO);
        return Result.success();
    }

    /**
     * 查询宠物领养申请进度
     */
    @GetMapping("/petAdoptApplication")
    private Result<List<PetAdoptApplicationVO>> selectPetAdoptApplication(){

        return Result.success(petAdoptApplicationService.selectPetAdoptApplication());
    }

    /**
     * 取消宠物领养申请
     */
    @DeleteMapping("/petAdoptApplication")
    public Result petAdoptApplication(@RequestParam Long id){
        log.info("取消宠物领养申请:{}",id);
        petAdoptApplicationService.deletePetAdoptApplication(id);
        return Result.success();
    }

    /**
     * 修改宠物领养申请
     */
    @PutMapping("/petAdoptApplication")
    public Result petAdoptApplication(@RequestBody PetAdoptApplicationDTO dto){
        log.info("修改宠物领养申请:{}",dto);
        petAdoptApplicationService.updatePetAdoptApplication(dto);

        return Result.success();
    }
}
